﻿<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	{include file="public/css"}
	<title>培训机构申请列表</title>
</head>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i>首页<span class="c-gray en">&gt;</span>
		在线申请
		<span class="c-gray en">&gt;</span>
		培训机构申请列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
			<i class="Hui-iconfont">
				&#xe68f;
			</i>
		</a>
	</nav>
	<div class="page-container">
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l">
				<a href="javascript:;" class="btn btn-danger radius delAll">
					<i class="Hui-iconfont">&#xe6e2;</i>
					批量删除
				</a>
			</span>
			<span class="r">
				共有数据：<strong>{:$list->total()}</strong>条
			</span>
		</div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
				<thead>
					<tr class="text-c">
						<th width="25"><input type="checkbox" name="" value=""></th>
						<th width="50">ID</th>
						<th>机构名称</th>
						<th>联系人</th>
						<th>联系电话</th>
						<th>考级地址</th>
						<th>申请时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="n"}
					<tr class="text-c">
						<td>
							<input type="checkbox" name="ids" value="{$n.id}">
						</td>
						<td>{$n.id}</td>
						<td>{$n.name}</td>
						<td>{$n.contact}</td>
						<td>{$n.tel}</td>
						<td>{$n.address}</td>
						<td>{:date("Y-m-d",$n.time)}</td>
						<td>
							{if condition="$n.state eq 0"}
							<a style="cursor: pointer;color: green;font-weight: bold;" class="editState" data-state='1' data-id="{$n.id}" data-tel="{$n.tel}">同意</a>
							<a style="cursor: pointer;color: green;font-weight: bold;" class="editState" data-state='2' data-id="{$n.id}">拒绝</a>
							{else /}
							{:$n.state==1?'<font color="green">已同意</font>':''}{:$n.state==2?'<font color="red">已拒绝</font>':''}
							{/if}
						</td>
						<td class="f-14 td-manage">
							<a style="text-decoration:none" class="ml-5 del" href="javascript:;" data-id="{$n.id}" title="删除">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div class="page">{:$list->render()}</div>
		</div>
	</div>
	<!--_footer 作为公共模版分离出去-->	
	{include file="public/js"}
	<!--/_footer 作为公共模版分离出去-->
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript">
		function del(id){
			var index=layer.confirm('确定删除数据？',{btn:['确定','取消']},function(){
				layer.close(index);
				$.post("{:url('del')}",{id:id,sql:'apply',img:''},function(res){
					if (res.state==200) {
						layer.msg(res.msg,{icon:1,time:1500},function(){
							window.location.reload();
						})
					}else{
						layer.msg(res.msg,{icon:2,time:1500});
					}
				})
			})
		}
		$(".delAll").click(function(){
			var ids='';
			$("input[name=ids]:checked").each(function(){
				if (ids!='') {
					ids+=','+$(this).val();
				}else{
					ids=$(this).val();
				}
			})
			if (ids!='') {
				del(ids);
			}else{
				layer.msg('删除数据不能为空',{icon:2,time:1500});
			}
		})
		$(".del").click(function(){
			var id=$(this).attr('data-id');
			del(id);
		})
		$(".editState").click(function(){
			var state=$(this).attr('data-state');
				id=$(this).attr('data-id');
				tel=$(this).attr('data-tel');
			if (state==1) {
				var html="<form><div style='color:#000;position:absolute;top:50%;height:30%;width: 50%;margin: -10% 0 0 25%;'>账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号<input type='text' name='name' value=''></div><div style='color:#000;position:absolute;top:50%;width:50%;margin: 0 0 0 25%;'>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码<input type='text' name='paw' value=''></div><div style='color:#000;position:absolute;top:80%;width:50%;margin: 0 0 0 25%;'>手机号码<input type='text' value='"+tel+"' readonly></div></form>";
				var index=layer.open({
					type: 1,
					title: '设定账号密码',
					skin: 'layui-layer-rim', //加上边框
					area: ['420px', '240px'], //宽高
					btn:['确定','取消'],
					content: html,
					yes: function(){
						var name=$("input[name=name]").val();
							paw=$("input[name=paw]").val();
						//console.log(state);console.log(id);console.log(name);console.log(paw);
						if (name=='' || paw=='')  {
							layer.msg('请输入完整信息',{icon:7,time:1500});
						}else{
							$.post("{:url('apply_state')}",{state:state,id:id,name:name,password:paw},function(res){
								console.log(res);
								if (res.code==200) {
									layer.msg(res.msg,{icon:1,time:1500},function(){
										window.location.reload();
									})
								}else{
									layer.msg(res.msg,{icon:2,time:1500});
								}
							})
						}
					}
				});
			}else if(state==2){
				$.post("{:url('apply_state')}",{state:state,id:id},function(res){
					console.log(res);
					if (res.code==200) {
						layer.msg(res.msg,{icon:1,time:1500},function(){
							window.location.reload();
						})
					}else{
						layer.msg(res.msg,{icon:2,time:1500});
					}
				})
			}
		})
	</script>
</body>
</html>